home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / RoboSamSlot / AOCEEncList.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  4.6 KB  |  225 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        AOCEEncList.h
  3.  
  4.     Contains:    provides retrtieval and parsing of 'elst' blocks. Necessary for preserving
  5.                 enclosure hierarchy and folders.
  6.                 
  7.                 n.b. MSAMGetEnclosure does not return folders or any hierarchy info, thus this class
  8.  
  9.     Written by:    David Akhond
  10.  
  11.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  12.  
  13.     Change History (most recent first):
  14.  
  15.          <2>     3/16/95    HDA        do it right this time
  16.  
  17.     To Do:  
  18.     
  19.     
  20. */
  21.  
  22. #ifndef __OCE__
  23. #include "OCE.h"
  24. #endif
  25.  
  26. #ifndef __OCEMESSAGING__
  27. #include "OCEMessaging.h"
  28. #endif
  29.  
  30. #ifndef __OCEMAIL__
  31. #include "OCEMail.h"
  32. #endif
  33.  
  34. #ifndef __MEMORY__
  35. #include "Memory.h"
  36. #endif
  37.  
  38. #ifndef __TAOCEEnclosure__
  39. #include    "AOCEEnclosure.h"
  40. #endif
  41.  
  42. #ifndef _EncloseFileList_
  43. #include    "EnclosFile.h"
  44. #endif
  45.  
  46. #ifndef __FileUtils__
  47. #include    "FileUtils.h"
  48. #endif
  49.  
  50.  
  51. //••••••••••••••••••••
  52.  
  53. #define        kMailBuffSize        1024
  54.  
  55.  
  56. //••••••••••••••••••••••
  57.  
  58. typedef    struct{
  59.  
  60.     unsigned short        fileCount;
  61.     unsigned short        folderCount;
  62.  
  63. }EnclCount;
  64.  
  65.  
  66. typedef    struct{
  67.  
  68.     unsigned short        parentsBlockIndex;
  69.     unsigned short        parentsContainerIndex;
  70.  
  71. }ParentIndex;
  72.  
  73.  
  74. typedef    struct{
  75.  
  76.     unsigned short        selfBlockIndex;
  77.     unsigned short        selfContainerIndex;        // index in the current Block, not globally
  78.     unsigned long        selfOffsetInBlock;
  79.  
  80. }SelfIndex;
  81.  
  82. typedef struct{
  83.  
  84.     char                containerName[32];            // name of the container (file or folder) 
  85.     
  86.     unsigned short        asglIndex;                    // this is index is used by 'edsk' processing. it tells the index of the 'asgl' segment the AppleSingle form of the file is stored in
  87.     unsigned short        attribs;                    // attributes
  88.  
  89.     union{
  90.     
  91.         FInfo    fileInfo;
  92.         DInfo    dirInfo;
  93.     
  94.     }    fndrInfo;
  95.     
  96.     unsigned long    dataLen,
  97.                     rsrcLen,
  98.                     crDate,
  99.                     modDate,
  100.                     bkDate;
  101.     
  102.     union{
  103.     
  104.         FXInfo    fileXInfo;
  105.         DXInfo    dirXInfo;
  106.     
  107.     }    fndrXInfo;
  108.     
  109.     unsigned long    clmpSize;                    // who knows what this does?
  110.     
  111.     Boolean            contentEnclosure;            // true if this is a mainContentEnclosure, otherwise false
  112.     
  113.     Boolean            padByte;                    // this is whatever garbage happened to be in memory at the time. NOT ZEROED OUT, don't assume it is!
  114.  
  115. }             ElstDescriptor;
  116.  
  117.  
  118. typedef    struct{
  119.  
  120.         SelfIndex            selfInfo;
  121.         
  122.         ParentIndex            contextInfo;
  123.         
  124.         short                 vRefNum;
  125.         long                 dirID;
  126.         
  127.         ElstDescriptor        containerDescriptor;
  128.  
  129. }                ElstContainer;
  130.  
  131.  
  132. //••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  133.  
  134.  
  135. #ifndef __TAOCEEncList__
  136. #define __TAOCEEncList__
  137.  
  138.  
  139. //-------------------------------------------------
  140. //            TAOCEEncList
  141. //-------------------------------------------------
  142.  
  143. class    TAOCEEncList {
  144.  
  145. public:                    
  146.                         TAOCEEncList();
  147.                         ~TAOCEEncList();
  148.  
  149.         void            IAOCEEncList(MailMsgRef        myMsgRef, TAOCEEnclosure        *theAEnclos);
  150.         
  151.         void            CountEListBlocks();
  152.         
  153.         void            GetEListBuffer();
  154.  
  155.         char            ElstByte();
  156.         
  157.         short            ElstShort();
  158.         
  159.         void            NextContainer();
  160.         
  161.         void            AllContainers();
  162.         
  163.         unsigned short    FolderCount() {return    fFolderCount;};
  164.         
  165.         unsigned short    FileCount() {return    fFileCount;};
  166.         
  167.         Boolean            ContainerIsFolder(ElstContainer*     theContainer);
  168.         
  169.         Boolean            ContainerIsFile(ElstContainer*     theContainer);
  170.         
  171.         void            CreateDirectoryStructure(CFolder        *theFolder);
  172.         
  173.         void            GetContainerParent(ElstContainer    *theContainer, short    *vRefNum, long    *parDirID);
  174.         
  175.         void            WriteFiles();
  176.         
  177.         void            WriteEnclosureFile(ElstContainer        *eListContainer, short *vRefNUm, long *parDirID);
  178.         
  179. private:
  180.  
  181.         MailMsgRef            fMsgRef;
  182.         
  183.         TAOCEEnclosure*        fTheAEnclos;
  184.         
  185.         ElstContainer        fPrimaryEList[50];        // this is done  out of sheer laziness. AOCEEnclosure segment is a pig anyway, so why not another 5K?
  186.         long                fDirID[50];                // initialized to 0, these are set when a directory is written to disk as the destination for enclosures.
  187.                                                     // Maps 1 to 1 with the fPrimaryEList.
  188.         
  189.         unsigned short        fCurrEListBlockIndex;        // index of block
  190.         unsigned short        fCurrContainerIndex;        // index in the current block
  191.         unsigned short        fGlobalContainerIndex;        // index in all blocks (the segment), used as the fPrimaryEList array's index, ordinal
  192.         
  193.         
  194.         Ptr                    fGetBuffer;                // where MSAMGetBlock returns its data
  195.         long                fBuffDataSize;
  196.         
  197.         long                fBuffDataOffset;        // where we are in the current buffer
  198.         unsigned long        fBlockDataOffset;        // where we are in the current block
  199.         unsigned long        fNextBlockDataOffset;    // where the next data block starts
  200.         
  201.         Boolean                fEndOfBlock;
  202.         Boolean                fEncListPrepped;
  203.         
  204.         unsigned short        fEListBlocksCount;
  205.         
  206.         short                fEnclosuresCount;
  207.         
  208.         short                fFileCount;
  209.         short                fFolderCount;
  210.         
  211.         short                fCurrBlocksParentBlockIndex;
  212.         short                fCurrBlocksParentContainerIndex;
  213.         
  214.         OSErr                fGetBuffErr;
  215.         
  216.         CFolder*            fRootFolder;
  217.         CEnclosFileSummary*  fReturnSummary;
  218.  
  219. };
  220.  
  221.  
  222.  
  223.  
  224.  
  225. #endif __TAOCEEncList__